# NSSCTF
# AKKPLX


a='AKKPLX{qv5x0021-7n8w-wr05-x25w-7882ntu5q984}'
letter_list = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'  # 字母表

def de1(ciphertext):
    key_list=[13,18,18]
    plaintext = ""
    i = 0
    for ch in ciphertext:  # 遍历密文
        if 0 == i % len(key_list):
            i = 0
        if ch.isalpha():  # 密文为否为字母,如果是,则判断大小写,分别进行解密
            if ch.isupper():
                plaintext += letter_list[(ord(ch) - 65 - key_list[i]) % 26]
                i += 1
            else:
                plaintext += letter_list[(ord(ch) - 97 - key_list[i]) % 26].lower()
                i += 1
        else:  # 如果密文不为字母,直接添加到明文字符串里
            plaintext += ch

    return plaintext


#爆破秘钥
a1="AKKPLX"
a2="NSSCTF"
for j in range(len(a1)):
    for i in range(0,26):
        tmp= chr((ord(a1[j]) - 65 - i) % 26+65)
        if a2[j]==tmp:
            print(i)
            break
flag=de1(a)
print(flag)
